package com.ruoyi.center.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.center.domain.ManagementTeam;
import com.ruoyi.center.service.IManagementTeamService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 管理团队Controller
 * 
 * @author ruoyi
 * @date 2025-11-08
 */
@RestController
@RequestMapping("/center/management")
public class ManagementTeamController extends BaseController
{
    @Autowired
    private IManagementTeamService managementTeamService;

    /**
     * 查询管理团队列表
     */
    @PreAuthorize("@ss.hasPermi('center:management:list')")
    @GetMapping("/list")
    public TableDataInfo list(ManagementTeam managementTeam)
    {
        startPage();
        List<ManagementTeam> list = managementTeamService.selectManagementTeamList(managementTeam);
        return getDataTable(list);
    }

    /**
     * 导出管理团队列表
     */
    @PreAuthorize("@ss.hasPermi('center:management:export')")
    @Log(title = "管理团队", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ManagementTeam managementTeam)
    {
        List<ManagementTeam> list = managementTeamService.selectManagementTeamList(managementTeam);
        ExcelUtil<ManagementTeam> util = new ExcelUtil<ManagementTeam>(ManagementTeam.class);
        util.exportExcel(response, list, "管理团队数据");
    }

    /**
     * 获取管理团队详细信息
     */
    @PreAuthorize("@ss.hasPermi('center:management:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(managementTeamService.selectManagementTeamById(id));
    }

    /**
     * 新增管理团队
     */
    @PreAuthorize("@ss.hasPermi('center:management:add')")
    @Log(title = "管理团队", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ManagementTeam managementTeam)
    {
        return toAjax(managementTeamService.insertManagementTeam(managementTeam));
    }

    /**
     * 修改管理团队
     */
    @PreAuthorize("@ss.hasPermi('center:management:edit')")
    @Log(title = "管理团队", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ManagementTeam managementTeam)
    {
        return toAjax(managementTeamService.updateManagementTeam(managementTeam));
    }

    /**
     * 删除管理团队
     */
    @PreAuthorize("@ss.hasPermi('center:management:remove')")
    @Log(title = "管理团队", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(managementTeamService.deleteManagementTeamByIds(ids));
    }
}
